package com.scau.ums.service.imp.password;

import com.scau.ums.service.Password;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * author: 莫伟杰
 * date： 2019/8/6 14:30
 */

public abstract class PasswordImp implements Password {
    @Override
    public abstract boolean resetPassword(String userID);

    @Override
    public abstract boolean changePassword(String userID, String oldPwd, String newPwd);

    @Override
    public String encode(String password) {
        PasswordEncoder encoder = new BCryptPasswordEncoder();
        return encoder.encode(password);
    }

    @Override
    public boolean matches(String password,String encoded) {
        PasswordEncoder decoder = new BCryptPasswordEncoder();
        return decoder.matches(password,encoded);
    }
}
